package scientistengineer.blogspot.affrpor;

import android.app.Activity;
import android.content.Context;
import android.content.Intent;
import android.view.View;
import android.widget.AdapterView;
import android.widget.ListView;
import android.widget.AdapterView.OnItemClickListener;

public class MenuListIconTitle extends Activity {
	
	private RowIconText [] row_data;
	private IconTextAdapter adapter;
	
	public MenuListIconTitle(final Context context, final RowIconText [] iconTitle, ListView listViewMenu) 
	{
		
		row_data = iconTitle;
		
		adapter = new IconTextAdapter(context, R.layout.listview_icon_text, row_data);
		
	    listViewMenu.setAdapter(adapter);
		listViewMenu.setOnItemClickListener(new OnItemClickListener()
		{
			@Override
			public void onItemClick(AdapterView<?> parent, View view,
					int position, long id) {
					
				/*
					try {
						Intent launchActivity = new Intent(context, Class.forName(row_data[position].getTextView()+".class"));
						startActivity(launchActivity);
					} catch (ClassNotFoundException e) {
						// TODO Auto-generated catch block
						e.printStackTrace();
					}*/
				
			}
		}); 
	}
		
	
	
	public MenuListIconTitle(final Context context, int [] icon, final String [] title, int listViewXml )
	{
		row_data= new RowIconText[icon.length];
		for(int count=0; count<icon.length; count++)
		{
			row_data[count] = new RowIconText(icon[count], title[count]);
		}
		adapter = new IconTextAdapter(context, R.layout.listview_icon_text, row_data);
		ListView listViewMenu = (ListView)findViewById(listViewXml);
		listViewMenu.setAdapter(adapter);
		listViewMenu.setOnItemClickListener(new OnItemClickListener()
		{
			@Override
			public void onItemClick(AdapterView<?> parent, View view,
					int position, long id) {
					
					try {
						Intent launchActivity = new Intent(context, Class.forName(title[position]+".class"));
						startActivity(launchActivity);
					} catch (ClassNotFoundException e) {
						// TODO Auto-generated catch block
						e.printStackTrace();
					}
				
			}
		});
	}

}
